//
//  TableCellDetailCollectionViewCell.m
//  TextApplication
//
//  Created by dllo on 16/9/9.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "TableCellDetailCollectionViewCell.h"
#import "TAMacro.h"
#import "UIImageView+WebCache.h"
#import "CollectionViewItems.h"

#import "CollectionViewBrand.h"
#import "CollectionViewItems.h"

@interface TableCellDetailCollectionViewCell ()
@property (nonatomic, strong) UIImageView *picImageView;
@property (nonatomic, strong) UILabel *goodNameLabel;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *priceLabel;
@property (nonatomic, strong) UILabel *likeLabel;

@property (nonatomic, strong) UIImageView *moneyImageView;
@property (nonatomic, strong) UIImageView *likeImageView;


@end

@implementation TableCellDetailCollectionViewCell
// 重写setter方法
- (void)setCollectData:(CollectionViewItems *)collectData {
    _collectData = collectData;
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:self.collectData.goods_image]];
    _goodNameLabel.text = self.collectData.goods_name;
    _nameLabel.text = self.collectData.brand_info.brand_name;
    _priceLabel.text = self.collectData.price;
    _likeLabel.text = self.collectData.like_count;
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        _picImageView = [[UIImageView alloc] init];
        _goodNameLabel = [[UILabel alloc] init];
        _nameLabel = [[UILabel alloc] init];
        _priceLabel = [[UILabel alloc] init];
        _likeLabel = [[UILabel alloc] init];
        
        _moneyImageView = [[UIImageView alloc] init];
        _likeImageView = [[UIImageView alloc] init];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.contentView.backgroundColor = [UIColor colorWithWhite:0.203 alpha:1.000];
    _picImageView.frame = CGRectMake(0, 0, CONTENTWIDTH, CONTENTWIDTH);
    [self.contentView addSubview:_picImageView];
    
    _goodNameLabel.frame = CGRectMake(5, CONTENTWIDTH + 10, CONTENTWIDTH - 10, 20);
    _goodNameLabel.textColor = [UIColor whiteColor];
    [self.contentView addSubview:_goodNameLabel];
    
    _nameLabel.frame = CGRectMake(5, CONTENTWIDTH + 20 + 10 + 10, CONTENTWIDTH - 10, 20);

    _nameLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:_nameLabel];

    _moneyImageView.frame = CGRectMake(5, CONTENTWIDTH + 70, 20, 20);
    _moneyImageView.image = [UIImage imageNamed:@"27"];
    [self.contentView addSubview:_moneyImageView];
    
    _priceLabel.frame = CGRectMake(25, CONTENTWIDTH + 40 + 10 + 20, (CONTENTWIDTH - 35) / 4 * 2, 20);
    _priceLabel.textColor = [UIColor colorWithRed:0.353 green:0.588 blue:0.890 alpha:1.000];
    [self.contentView addSubview:_priceLabel];
    
    _likeImageView.frame = CGRectMake((CONTENTWIDTH - 30) / 4 * 2 + 30, CONTENTWIDTH + 40 + 10 + 20, 20, 20);
    _likeImageView.image = [UIImage imageNamed:@"28"];
    [self.contentView addSubview:_likeImageView];
    
    _likeLabel.frame = CGRectMake((CONTENTWIDTH - 30) / 4 * 2 + 30 + 20 + 5, CONTENTWIDTH + 40 + 10 + 20, CONTENTWIDTH - ((CONTENTWIDTH - 30) / 4 * 2 + 30 + 25) - 5, 20);
    
    _likeLabel.textColor = [UIColor colorWithRed:0.353 green:0.588 blue:0.890 alpha:1.000];
    [self.contentView addSubview:_likeLabel];
}


@end
